Skip to content

Fix admin chat preserve_thinking history serialization#1329

Merged
jundot merged 1 commit into
jundot:mainfrom
gindinconsulting:fix-admin-chat-preserve-thinking
May 21, 2026
Merged

Fix admin chat preserve_thinking history serialization#1329
jundot merged 1 commit into
jundot:mainfrom
gindinconsulting:fix-admin-chat-preserve-thinking

Conversation

@gindinconsulting

Copy link
Copy Markdown

Summary

Fixes preserve_thinking in the built-in admin chat UI.

The raw /v1/chat/completions API preserves historical reasoning correctly when prior assistant messages include reasoning_content. However, the admin chat UI was storing streamed reasoning only in the UI-private _thinking field and then dropping it when serializing conversation history for the next request.

This made preserve_thinking work with raw API calls but fail inside the built-in chat.

Changes

  • Include reasoning_content when building messagesForApi
  • Fall back to _thinking so existing localStorage conversations continue to work
  • Store streamed thinking as both:
    • reasoning_content, for API history replay
    • _thinking, for existing UI rendering
  • Preserve reasoning on normal assistant messages, aborted streams, and assistant tool-call turns

Manual test

Tested locally with Qwen3.6-35B-A3B-oQ8-mtp.

Prompt 1:

Generate two random 20-digit numbers, validate that both are 20 digits, do not use tools, and only give me one of the two.

Prompt 2:

Now give me the second number only.

Before this fix, the built-in chat could not retrieve the hidden second number because prior reasoning was not sent back. After this fix, the built-in chat returns the second number from preserved reasoning history.

@jundot

jundot commented May 21, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix. Confirmed the server already reconstructs reasoning_content from history (api/utils.py), so the only gap was the admin chat dropping it during serialization, exactly as you described. The _thinking fallback for existing localStorage conversations is a nice touch. Merging this.

@jundot jundot merged commit cf4023c into jundot:main May 21, 2026
jonpspri pushed a commit to jonpspri/omlx that referenced this pull request Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants